from tkinter import *
from tkinter import messagebox

"""将窗口与app联系起来"""
class Application(Frame):
    """一个经典的GUI程序的方法"""
    def __init__(self,master=None):
        super().__init__(master)
        #调用父类frame，super()代表父类的定义
        self.master =master
        self.pack()
        self.creatWeight()

    """创建组件"""
    def creatWeight(self):
    #add a photo
        global photo01
        photo01 = PhotoImage(file=r"C:\Users\l1530\Desktop\Grand Theft Auto V Screenshot 2024.11.26 - 22.04.52.86.png")
        self.label01 = Label(self, image=photo01,width=100,
                             height=80)
        self.label01.pack()
    #add a few letter
        self.label02 = Label(self,text='hfjak\n\thkwfaj\t\t\ndgh',relief='solid',
                             borderwidth=1,justify='center')
        self.label02.pack()

    #add a Button to make the next command('songhua')
        self.bin01 = Button(self,text='送花',width=6,height=2)
        self.bin01.pack()       #将按钮放置于root窗口中
        self.bin01["command"] = self.songhua
    #创建一个他退出按钮
        self.binquit = Button(self,text = "退出",command=root.destroy)
        self.binquit.pack()


    def songhua(self):
        messagebox.showinfo("送花","su")

if __name__ == '__main__':
    """创建窗口"""
    root =Tk()
    root.title("first")
    root.geometry("600x500")
    app =Application(master=root)
    root.mainloop()


















